package org.gdpu.Service.Impl;

import org.gdpu.Service.MaintainingService;
import org.gdpu.Service.PowerGroupService;
import org.gdpu.base.DaoSupport;
import org.gdpu.model.Dormitory;
import org.gdpu.model.Maintaining;
import org.gdpu.model.MaintainingState;
import org.gdpu.model.PowerGroup;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.directwebremoting.*;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by HEWI2 on 2/17/14.
 */

@Service
@Transactional
public class MaintainingServiceImpl extends DaoSupport<Maintaining> implements MaintainingService {

    @Override
    public List<Maintaining> findResultByDormitory(Dormitory dormitory) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("dormitory", dormitory);
        return (List<Maintaining>) this.findByFields(Maintaining.class, params);
    }

    @Override
    public List<Maintaining> findResult() {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("state", MaintainingState.NOT_AUDIT);
        return (List<Maintaining>) this.findByFields(Maintaining.class, params);
    }

    @Override
    public Maintaining findResult(int id) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        return (Maintaining) this.findSpecialObject(Maintaining.class, params);
    }
}
